import type { BaseUser, PutUserInfo, UserId, UserIdfan } from '../types/user';
import { http } from '../utils/httpRequest';
type LoginParams = {
	code : string
}

/** 小程序登录*/
export const Userlogin = (data : LoginParams) => {
	return http({
		method: 'POST',
		url: '/wx/v1/user/login',
		data,
	});
};

// 获取用户信息
export const GetUserinfo = (data : UserId) => {
	return http({
		url: '/wx/v1/user/userinfo',
		method: 'GET',
		data,
	});
};


// 修改用户信息
export const PutUserinfo = (data : PutUserInfo) => {
	return http({
		url: '/wx/v1/user/userinfo',
		method: 'PUT',
		data,
	});
};

// 修改用户头像
export const PutAvatar = () => {
	return http({
		url: '/wx/v1/user/avatar',
		method: 'PUT',
	});
};

// 查询用户发布的帖子列表（返回的帖子信息是简略的，点击帖子后转到帖子详情页进行操作）
export const GetUserPost = (data : UserIdfan) => {
	return http({
		url: '/wx/v1/user/post',
		method: 'GET',
		data,
	});
};

// 查询用户的关注列表
export const GetFollowers = (data : UserIdfan) => {
	return http({
		url: '/wx/v1/user/followers',
		method: 'GET',
		data,
	});
};

// 查询用户的粉丝列表
export const GetFans = (data : UserIdfan) => {
	return http({
		url: '/wx/v1/user/myFans',
		method: 'GET',
		data,
	});
};

// 查询用户的收藏的帖子
export const GetCollection = (data : UserIdfan) => {
	return http({
		url: '/wx/v1/user/favorite/post',
		method: 'GET',
		data,
	});
};


// 关注和取消关注
export const PostConcern = (data : UserId) => {
	return http({
		url: '/wx/v1/user/followers',
		method: 'POST',
		data,
	});
};
